/*
 * IkaCore.h
 */

#ifndef IKACORE_H_
#define IKACORE_H_

#include<iostream>
#include"IkaAnim.h"
#include"IkaString.h"
#include"define.h"

namespace atomic {

/**
 * Basic object (or "brick") of the game
 */
class IkaCore {
public:

	/**
	 * Defaut constructor
	 */
	IkaCore();

	/**
	 * Full constructor
	 */
	IkaCore(float x, float y, atomic::IkaAnim* anims, unsigned int width = 10,
			unsigned int height = 40, float scrollFactor = 1.0f, bool exists =
					true, bool active = true, bool dead = false, bool visible =
					true, unsigned int myMaxAnims = 0,
			unsigned int myAnimsCount = 0);

	/**
	 * Re-initialization of attributes
	 */
	void Init();

	/**
	 * Constructor by copy
	 */
	IkaCore(const IkaCore &copy);

	/**
	 * Operator =
	 */
	atomic::IkaCore& operator=(const atomic::IkaCore &core);

	/**
	 * Destructor
	 */
	virtual ~IkaCore();

	/**
	 * Update datas when called
	 */
	void Update();

	/**
	 * Prints the IkaCore on the screen according to datas
	 */
	void Render();

	/**
	 * Checks if this IkaCore overlaps with another one
	 *
	 * \param core : another IkaCore
	 * \return true if overlaps
	 */
	bool Overlaps(const atomic::IkaCore &core);

	/**
	 * Checks if this IkaCore overlaps with a point
	 *
	 *\param x : abscissa of the point
	 *\param y : ordinate of the point
	 *\return true if overlaps with this point
	 */
	bool OverlapsPoint(float x, float y);
	// bool HitWall();
	// bool HitFloor();
	// bool HitCeiling();

	/**
	 * Kill this IkaCore
	 */
	void Kill();
	// void Flicker(float duration);
	// bool Flickering();

	/**
	 * Checks if this IkaCore is on the screen
	 * \return true if this IkaCore appears on the screen
	 */
	bool OnScreen() const;

	/**
	 * Is this IkaCore active?
	 * \return true if it is
	 */
	bool Active() const;

	/**
	 * Is this IkaCore dead?
	 * \return true if dead
	 */
	bool Dead() const;

	/**
	 * Is this IkaCore exists?
	 * \return true if this IkaCore exists
	 */
	bool Existent() const;

	/**
	 * Is this IkaCore is visible?
	 * \return true if visible
	 */
	bool Visible() const;

	/**
	 * Get the height of the image of this IkaCore
	 * \return the height in pixels
	 */
	int Height() const;

	/**
	 * Get the scroll factor (useful for parallaxing) of this IkaCore
	 * \return the factor of scrolling
	 */
	float ScrollFactor() const;

	/**
	 * Get the width of the image of this IkaCore
	 * \return the width in pixels
	 */
	int Width() const;

	/**
	 * Get the x position of the image of this IkaCore
	 * \return the X position
	 */
	float X() const;

	/**
	 * Get the y position of the image of this IkaCore
	 * \return the Y position
	 */
	float Y() const;

	/**
	 * Get the full array of animations
	 * \return an reference on the vector of IkaAnim
	 */
	std::vector<atomic::IkaAnim>& Anims() const;

	/**
	 * Set a new 'active' value
	 * \param the new 'active' value (boolean)
	 */
	void SetActive(bool active);

	/**
	 * Set a new 'dead' value
	 * \param the new 'dead' value (boolean)
	 */
	void SetDead(bool dead);

	/**
	 * Set a new 'existence' value
	 * \param the new 'existence' value (boolean)
	 */
	void SetExistent(bool existent);

	/**
	 * Set a new 'visibility' value
	 * \param the new 'visibility' value (boolean)
	 */
	void SetVisible(bool visible);

	/**
	 * Set a new scrollFactor value
	 * \param the new scrollFactor value (float)
	 */
	void SetScrollFactor(float scrollFactor);

	/**
	 * Set a new X value
	 * \param the new X value (float)
	 */
	void SetX(float x);

	/**
	 * Set a new Y value
	 * \param the new Y value (float)
	 */
	void SetY(float y);

	/**
	 * Set a new Anim at a specific position in the vector
	 * \param anim : the new anim to set
	 * \param index : the position
	 */
	bool SetAnim(atomic::IkaAnim& anim, unsigned int index);

	/**
	 * Add a new anim using a src (string)
	 * \param name : the name of the new anim
	 */
	void AddAnim(std::string name);

protected:

	/**
	 * Set a new height value
	 * \param the new height value in pixels
	 */
	void SetHeight(unsigned int height);

	/**
	 * Set a new width value
	 * \param the new width value in pixels
	 */
	void SetWidth(unsigned int width);

	/**
	 * Convenience attribute of existence
	 */
	bool isExistent;

	/**
	 * Flag for the active/passive mode of the IkaCore (like a switch)
	 */
	bool isActive;

	/**
	 * Flag for invisibility
	 */
	bool isVisible;

	/**
	 * Flag for death and suppression
	 */
	bool isDead;

	/**
	 * X position
	 */
	float myX;

	/**
	 * Y Position
	 */
	float myY;

	/**
	 * Width of the IkaCore
	 */
	unsigned int myWidth;

	/**
	 * Height of the IkaCore
	 */
	unsigned int myHeight;

	/**
	 * Reaction to the camera movements
	 * 1.0 : move like an object on the first plan
	 * 0.0 : no move (infinite distance from the camera)
	 */
	float myScrollFactor;

	/**
	 * Vector containing animations
	 */
	std::vector<IkaAnim> myAnims;

	/**
	 * Active animation
	 */
	int myCurrentAnim;

	/**
	 * Current frame of the active animation
	 */
	int myCurrentFrame;
	// TODO 03 PlayAnim(name) : render;

};

}

#endif /* IKACORE_H_ */
